<template>
  <select :value="modelValue" @input="handleInput">
    <option disabled value="">请选择文件类型</option>
    <option value="all">所有类型</option>
    <option value="document">文档（.pdf, .docx, .txt）</option>
    <option value="spreadsheet">表格（.xls, .xlsx, .csv）</option>
    <option value="presentation">演示文稿（.ppt, .pptx）</option>
    <option value="image">图片（.jpg, .png, .gif）</option>
    <option value="video">视频（.mp4, .avi, .mkv）</option>
    <option value="audio">音频（.mp3, .wav）</option>
    <option value="archive">压缩包（.zip, .rar, .7z）</option>
    <option value="plugin">插件/扩展（.jar, .dll, .plugin）</option>
    <option value="executable">可执行文件（.exe, .apk）</option>
    <option value="code">代码文件（.js, .ts, .html）</option>
    <option value="model">三维模型（.obj, .fbx, .blend）</option>
    <option value="other">其他</option>
  </select>
</template>

<script lang="ts">
import { defineComponent, toRefs } from 'vue';

export default defineComponent({
  name: 'SearchTypeSelector',
  props: {
    modelValue: {
      type: String,
      required: true
    }
  },
  setup(props, { emit }) {
    // 获取传入的 modelValue
    const { modelValue } = toRefs(props);

    // 处理 input 事件
    const handleInput = (event: Event) => {
      const target = event.target as HTMLSelectElement; // 确保 target 是 HTMLSelectElement
      if (target) {
        emit('update:modelValue', target.value); // 发出事件，传递选中的值
      }
    };

    return {
      modelValue,
      handleInput
    };
  }
});
</script>

